<!-- views/user/List.vue -->
<template>
    <div>
        <el-button @click="router.push('/user/add')">新增</el-button>
        <el-table :data="tableData">
            <el-table-column prop="username" label="用户名" />
            <el-table-column label="操作">
                <template #default="{ row }">
                    <el-button @click="edit(row.id)">编辑</el-button>
                    <el-button @click="del(row.id)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination :total="100" @current-change="fetchData" />
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const tableData = ref([])

// 假装调接口
const fetchData = () => tableData.value = [
    { id: 1, username: 'admin' },
    { id: 2, username: 'user' }
]
</script>